﻿using System;
using System.Text.RegularExpressions;

namespace converter.template
{
    // The Size element representation.
    public sealed class Size
    {
        // Fields

        private double sizeValue;
        private string units;

        // Constructors

        // Constructs a new instance with values parsed from the value parameter.
        public Size(string value)
        {
            string pattern = @"(\d*\.*\d*)\s*(.*)";
            Match match = Regex.Match(value, pattern);
            sizeValue = Convert.ToDouble(match.Groups[1].Value);
            units = match.Groups[2].Value;
        }

        // Accessors

        // Gets a numeric value of the size.
        public double Value
        {
            get { return sizeValue; }
        }

        // Gets units the size is measured in.
        public string Units
        {
            get { return units; }
        }
    }
}
